package com.ssf.framework.vo;

import org.n3r.eql.EqlPage;

/**
 * Created by liolay on 14-12-29.
 */
public class Paging {
    private int currPage;
    private int totalPage;
    private int pageSize;
    private int totalRows;
    private String template;
    private EqlPage eqlPage = new EqlPage();

    public int getTotalRows() {
        return eqlPage.getTotalRows();
    }

    public void setTotalRows(int totalRows) {
        this.totalRows = totalRows;
    }

    public EqlPage getEqlPage() {
        eqlPage.setStartIndex((pageSize * (currPage - 1)));
        eqlPage.setPageRows(pageSize);
        return eqlPage;
    }

    public void setEqlPage(EqlPage eqlPage) {
        this.eqlPage = eqlPage;
    }

    public String getTemplate() {
        return template;
    }

    public void setTemplate(String template) {
        this.template = template;
    }

    public int getCurrPage() {
        return currPage;
    }

    public void setCurrPage(int currPage) {
        this.currPage = currPage;
    }

    public int getTotalPage() {
        int totalPages = eqlPage.getPageRows() <= 0 ? 0 : (eqlPage.getTotalRows() + eqlPage.getPageRows() - 1) / eqlPage.getPageRows();
        return totalPages < 1 ? 0 : totalPages;
    }

    public void setTotalPage(int totalPage) {
        this.totalPage = totalPage;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }
}
